<template>
  <div class="container">
    <van-popup round v-model="popupShow" @close="popupClose" position="bottom">
      <template v-if="popupState == 'picker'">
        <van-picker
          show-toolbar
          :columns="pickerData"
          @confirm="pickerConfirm"
          @cancel="pickerCancel"
        />
      </template>
      <template v-if="popupState == 'cascader'">
        <van-cascader
          :field-names="fieldNames"
          v-model="cascaderValue"
          title="请选择所属区域"
          :options="cascadeOptions"
          active-color="#D58913"
          @finish="cascaderFinish"
          @close="cascaderClose"
        />
      </template>
      <template v-if="popupState == 'map'">
        <Map
          v-if="popupState == 'map'"
          @getLngLat="getLngLat"
          :data="formData[0]"
        ></Map>
      </template>
      <template v-if="popupState == 'gtjzz'">
        <div style="height: 80vh; background: #f2f7fb">
          <Resident
            v-if="popupState == 'gtjzz'"
            @getResident="getResident"
            :resident_id="resident_id"
          ></Resident>
        </div>
      </template>
    </van-popup>

    <div class="container-inner">
      <van-form
        ref="form"
        label-width="110px"
        scroll-to-error
        :show-error-message="false"
        @failed="onFailed"
        @submit="onSubmit"
      >
        <div class="card base">
          <div class="card-bar">
            <div class="card-bar-title">本人基本信息</div>
          </div>
          <div class="card-container">
            <van-field
              v-model="formData[0].name"
              clearable
              maxlength="20"
              readonly
              :rules="[{ required: true, message: '请检查姓名' }]"
              name="name"
              label="姓名"
              input-align="right"
              placeholder="请输入姓名"
            >
            </van-field>
            <van-field
              v-model="formData[0].mobile"
              clearable
              maxlength="11"
              readonly
              :rules="[{ required: true, message: '请检查联系方式' }]"
              name="mobile"
              type="mobile"
              label="联系方式"
              input-align="right"
              placeholder="请输入联系方式"
            >
            </van-field>
            <van-field
              v-model="formData[0].card_no_tmd"
              clearable
              maxlength="18"
              readonly
              :rules="[{ required: true, message: '请检查身份证号' }]"
              name="card_no_tmd"
              label="身份证号"
              input-align="right"
              placeholder="请输入身份证号"
            >
            </van-field>
            <van-field
              v-model="formData[0].c_date"
              clearable
              maxlength="18"
              readonly
              :rules="[{ required: true, message: '请检查填报日期' }]"
              name="c_date"
              label="填报日期"
              input-align="right"
              placeholder="请输入填报日期"
            >
            </van-field>
            <van-field
              v-model="formData[0].hs_time || '无'"
              readonly
              name="hs_time"
              label="核酸检测时间"
              input-align="right"
            >
            </van-field>
            <van-field
              v-model="formData[0].ym_time || '无'"
              readonly
              name="ym_time"
              label="疫苗接种情况"
              input-align="right"
            >
            </van-field>
          </div>
        </div>

        <div class="card condition mt20">
          <div class="card-bar">
            <div class="card-bar-title">基本情况</div>
          </div>
          <div class="card-container">
            <van-field
              name="body_situation"
              required
              :rules="[{ required: true, message: '请检查身体情况' }]"
              label="身体情况"
            >
              <template #input>
                <van-radio-group
                  v-model="formData[0].body_situation"
                  checked-color="#D58913"
                  direction="horizontal"
                  @change="radioChange($event, 'body_situation', 0)"
                >
                  <van-radio name="0">正常</van-radio>
                  <van-radio name="1">异常</van-radio>
                </van-radio-group>
              </template>
            </van-field>
            <van-field
              v-if="formData[0].body_situation == 1"
              name="discomfortArr"
              label="病症病状"
              required
              :rules="[{ required: true, message: '请检查必填项' }]"
            >
              <template #input>
                <van-checkbox-group
                  v-model="formData[0].discomfortArr"
                  direction="horizontal"
                >
                  <van-row>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="发热"
                        shape="square"
                        >发热</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="干咳"
                        shape="square"
                        >干咳</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="乏力"
                        shape="square"
                        >乏力</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="鼻塞"
                        shape="square"
                        >鼻塞</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="流涕"
                        shape="square"
                        >流涕</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="咽痛"
                        shape="square"
                        >咽痛</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="肌痛"
                        shape="square"
                        >肌痛</van-checkbox
                      >
                    </van-col>
                    <van-col span="12">
                      <van-checkbox
                        checked-color="#D58913"
                        name="结膜炎"
                        shape="square"
                        >结膜炎</van-checkbox
                      >
                    </van-col>
                    <van-col span="11">
                      <van-checkbox
                        checked-color="#D58913"
                        name="腹泻"
                        shape="square"
                        >腹泻</van-checkbox
                      >
                    </van-col>
                    <van-col span="24">
                      <van-checkbox
                        checked-color="#D58913"
                        name="嗅（味）觉减退（丧失）"
                        shape="square"
                        >嗅（味）觉减退（丧失）</van-checkbox
                      >
                    </van-col>
                  </van-row>
                </van-checkbox-group>
              </template>
            </van-field>
            <van-field
              v-model="formData[0].temperature"
              type="number"
              required
              maxlength="4"
              :rules="[
                {
                  required: true,
                  validator: tempValidator,
                  message: '请检查体温',
                },
              ]"
              name="temperature"
              label="体温"
              placeholder="请输入体温"
            >
            </van-field>
            <van-field
              readonly
              clickable
              is-link
              name="ascription"
              :value="formData[0].ascription"
              label="今日所属区域"
              placeholder="点击选择"
              @click="pickerChange('ascription')"
              required
              :rules="[{ required: true, message: '请检查今日所属区域' }]"
            >
            </van-field>
            <van-field
              v-model="formData[0].quarter"
              required
              clearable
              maxlength="20"
              :rules="[{ required: true, message: '请检查今日所属小区' }]"
              name="quarter"
              placeholder="请输入今日所属小区"
            >
              <template #label>
                <div class="field-title">今日所属小区</div>
                <div class="field-text">(或无则住宅楼名)</div>
              </template>
            </van-field>
            <van-field
              v-model="formData[0].address"
              rows="3"
              autosize
              label="今日详细地址"
              type="textarea"
              maxlength="255"
              placeholder="请输入今日详细地址"
              required
              :rules="[{ required: true, message: '请检查今日详细地址' }]"
            >
            </van-field>
            <van-field name="loc">
              <template #label>
                <div class="field-title">今日地址坐标</div>
                <div class="field-text">(可选)</div>
              </template>
              <template #input>
                <div class="w100 h100 mid">
                  <van-button
                    class="margin-l-auto"
                    style="width: 100px"
                    native-type="button"
                    size="small"
                    color="#D58913"
                    plain
                    @click="pickerChange('map')"
                    >{{
                      formData[0].lng && formData[0].lat ? '修改' : '选择'
                    }}</van-button
                  >
                </div>
              </template>
            </van-field>
          </div>
        </div>

        <div class="card school mt20" v-if="fillingList.length > 0">
          <div class="card-bar">
            <div class="card-bar-title">学校动态填报（消息通知）</div>
          </div>
          <div class="card-container">
            <van-field
              v-for="item in fillingList"
              :key="item.id"
              clearable
              required
              :rules="[
                { required: true, message: '请检查' + item.filling_contents },
              ]"
              :name="item.key_num"
              v-model="formData[0][item.key_num]"
              :label="item.filling_contents"
              :placeholder="'请输入' + item.filling_contents"
            >
            </van-field>
          </div>
        </div>

        <div class="card epidemic mt20">
          <div class="card-bar">
            <div class="card-bar-title">流行病学史</div>
          </div>
          <div class="card-container">
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.epidemic.desc1 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_lxbxs_zgdqljs_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查流行病学史' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_lxbxs_zgdqljs_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.epidemic.desc2 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_lxbxs_jwljs_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查流行病学史' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_lxbxs_jwljs_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.epidemic.desc3 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_lxbxs_jcfrhz_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查流行病学史' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_lxbxs_jcfrhz_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.epidemic.desc4 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_lxbxs_jcxggrz_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查流行病学史' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_lxbxs_jcxggrz_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.epidemic.desc5 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_lxbxs_jjx_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查流行病学史' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_lxbxs_jjx_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
          </div>
        </div>

        <div class="card risk mt20">
          <div class="card-bar">
            <div class="card-bar-title">风险人群</div>
          </div>
          <div class="card-container">
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.risk.desc1 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_lxbxs_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_lxbxs_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-subtitle">{{ dict.risk.subtitle1 }}</div>
              <div class="card-item-label">{{ dict.risk.desc2 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_jkll_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_jkll_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.risk.desc3 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_jzyx_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_jzyx_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.risk.desc4 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_xgfy_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_xgfy_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.risk.desc5 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_bj_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_bj_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
            <div class="card-container-item">
              <div class="card-item-label">{{ dict.risk.desc6 }}</div>
              <div class="card-item-content">
                <van-field
                  name="is_fxrq_nrsq_br"
                  :required="false"
                  :rules="[{ required: true, message: '请检查风险人群' }]"
                  label="本人"
                >
                  <template #input>
                    <van-radio-group
                      v-model="formData[0].is_fxrq_nrsq_br"
                      checked-color="#D58913"
                      direction="horizontal"
                    >
                      <van-radio name="1">是</van-radio>
                      <van-radio name="0">否</van-radio>
                    </van-radio-group>
                  </template>
                </van-field>
              </div>
            </div>
          </div>
        </div>

        <div class="card file mt20">
          <div class="card-bar">
            <div class="card-bar-title">上传附件</div>
          </div>
          <div class="card-container">
            <van-field label="核酸检测报告" name="nucleic_test_image">
              <template #input>
                <Uploader
                  v-model="formData[0].nucleic_test_image"
                  :max-count="1"
                  file-dir="dlSchool/health/hsbg"
                ></Uploader>
              </template>
            </van-field>
            <van-field label="健康码" name="health_code_image">
              <template #input>
                <Uploader
                  v-model="formData[0].health_code_image"
                  :max-count="1"
                  file-dir="dlSchool/health/jkm"
                ></Uploader>
              </template>
            </van-field>
            <van-field label="行程码" name="trip_code_image">
              <template #input>
                <Uploader
                  v-model="formData[0].trip_code_image"
                  :max-count="1"
                  file-dir="dlSchool/health/xcm"
                ></Uploader>
              </template>
            </van-field>
          </div>
        </div>

        <van-divider :style="{ borderColor: 'black' }" />

        <div class="card-container">
          <div class="card-gtjzz mid">
            <div class="card-gtjzz-title">
              备选共同居住人<br />
              <span style="font-size: 13px">(请点选或添加今日共同居住人)</span>
            </div>
            <div>
              <van-button
                class="card-gtjzz-btn"
                size="small"
                color="#D58913"
                native-type="button"
                style="width: 80px"
                plain
                @click="pickerChange('gtjzz')"
                >添加</van-button
              >
            </div>
          </div>
          <div class="residentlist">
            <div class="w100" v-for="item in residentList" :key="item.id">
              <van-row
                type="flex"
                justify="space-between"
                class="residentlist-item"
                :class="{ 'residentlist-item-active': item.isChecked }"
              >
                <van-col span="22" offset="1" class="">
                  <van-row type="flex" justify="start" class="w100">
                    <van-col span="24" class="mid bold">
                      {{ item.name }}
                      <div class="tag">
                        {{ item.relationship_name }}
                      </div>
                    </van-col>
                  </van-row>
                  <div class="desc">{{ item.card_no_tmd }}</div>
                  <div class="residentlist-item-bottom">
                    <van-button
                      class="residentlist-item-bottom-btn"
                      size="small"
                      :color="item.isChecked ? '#A3A3A3' : '#D58913'"
                      type="info"
                      native-type="button"
                      :text="item.isChecked ? '取消选中' : '选中'"
                      @click="item.isChecked = !item.isChecked"
                    />
                    <van-button
                      class="residentlist-item-bottom-btn"
                      size="small"
                      color="#D58913"
                      type="info"
                      native-type="button"
                      text="修改"
                      @click="editAction(item)"
                    />
                  </div>
                </van-col>
              </van-row>
              <van-collapse v-model="activeNames" v-if="item.isChecked">
                <van-collapse-item
                  :title="item.name"
                  :name="item.id"
                  :lazy-render="false"
                >
                  <div class="card base">
                    <div class="card-bar">
                      <div class="card-bar-title">基本信息</div>
                    </div>
                    <div class="card-container">
                      <van-field
                        v-model="item.form.name"
                        clearable
                        maxlength="20"
                        readonly
                        :rules="[{ required: true, message: '请检查姓名' }]"
                        name="name"
                        label="姓名"
                        input-align="right"
                        placeholder="请输入姓名"
                      >
                      </van-field>
                      <van-field
                        v-model="item.form.mobile"
                        clearable
                        maxlength="11"
                        readonly
                        :rules="[{ required: true, message: '请检查联系方式' }]"
                        name="mobile"
                        type="mobile"
                        label="联系方式"
                        input-align="right"
                        placeholder="请输入联系方式"
                      >
                      </van-field>
                      <van-field
                        v-model="item.form.card_no_tmd"
                        clearable
                        maxlength="18"
                        readonly
                        :rules="[{ required: true, message: '请检查身份证号' }]"
                        name="card_no_tmd"
                        label="身份证号"
                        input-align="right"
                        placeholder="请输入身份证号"
                      >
                      </van-field>
                      <van-field
                        v-model="item.form.hs_time || '无'"
                        readonly
                        name="hs_time"
                        label="核酸检测时间"
                        input-align="right"
                      >
                      </van-field>
                      <van-field
                        v-model="item.form.ym_time || '无'"
                        readonly
                        name="ym_time"
                        label="疫苗接种情况"
                        input-align="right"
                      >
                      </van-field>
                    </div>
                  </div>

                  <div class="card condition mt20">
                    <div class="card-bar">
                      <div class="card-bar-title">本人基本情况</div>
                    </div>
                    <div class="card-container">
                      <van-field
                        name="body_situation"
                        required
                        :rules="[{ required: true, message: '请检查身体情况' }]"
                        label="身体情况"
                      >
                        <template #input>
                          <van-radio-group
                            v-model="item.form.body_situation"
                            checked-color="#D58913"
                            direction="horizontal"
                            @change="
                              radioChange($event, 'body_situation', index)
                            "
                          >
                            <van-radio name="0">正常</van-radio>
                            <van-radio name="1">异常</van-radio>
                          </van-radio-group>
                        </template>
                      </van-field>
                      <van-field
                        v-if="item.form.body_situation == 1"
                        name="discomfortArr"
                        label="病症病状"
                        required
                        :rules="[{ required: true, message: '请检查必填项' }]"
                      >
                        <template #input>
                          <van-checkbox-group
                            v-model="item.form.discomfortArr"
                            direction="horizontal"
                          >
                            <van-row>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="发热"
                                  shape="square"
                                  >发热</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="干咳"
                                  shape="square"
                                  >干咳</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="乏力"
                                  shape="square"
                                  >乏力</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="鼻塞"
                                  shape="square"
                                  >鼻塞</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="流涕"
                                  shape="square"
                                  >流涕</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="咽痛"
                                  shape="square"
                                  >咽痛</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="肌痛"
                                  shape="square"
                                  >肌痛</van-checkbox
                                >
                              </van-col>
                              <van-col span="12">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="结膜炎"
                                  shape="square"
                                  >结膜炎</van-checkbox
                                >
                              </van-col>
                              <van-col span="11">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="腹泻"
                                  shape="square"
                                  >腹泻</van-checkbox
                                >
                              </van-col>
                              <van-col span="24">
                                <van-checkbox
                                  checked-color="#D58913"
                                  name="嗅（味）觉减退（丧失）"
                                  shape="square"
                                  >嗅（味）觉减退（丧失）</van-checkbox
                                >
                              </van-col>
                            </van-row>
                          </van-checkbox-group>
                        </template>
                      </van-field>
                      <van-field
                        v-model="item.form.temperature"
                        type="number"
                        required
                        maxlength="4"
                        :rules="[
                          {
                            required: true,
                            validator: tempValidator,
                            message: '请检查体温',
                          },
                        ]"
                        name="temperature"
                        label="体温"
                        placeholder="请输入体温"
                      >
                      </van-field>
                    </div>
                  </div>

                  <div class="card school mt20" v-if="fillingList.length > 0">
                    <div class="card-bar">
                      <div class="card-bar-title">学校动态填报（消息通知）</div>
                    </div>
                    <div class="card-container">
                      <van-field
                        v-for="fillingItem in fillingList"
                        :key="fillingItem.id"
                        clearable
                        required
                        :rules="[
                          {
                            required: true,
                            message: '请检查' + fillingItem.filling_contents,
                          },
                        ]"
                        :name="fillingItem.key_num"
                        v-model="item.form[fillingItem.key_num]"
                        :label="fillingItem.filling_contents"
                        :placeholder="'请输入' + fillingItem.filling_contents"
                      >
                      </van-field>
                    </div>
                  </div>

                  <div class="card epidemic mt20">
                    <div class="card-bar">
                      <div class="card-bar-title">流行病学史</div>
                    </div>
                    <div class="card-container">
                      <div class="card-container-item">
                        <div class="card-item-label">
                          {{ dict.epidemic.desc1 }}
                        </div>
                        <div class="card-item-content">
                          <van-field
                            name="is_lxbxs_zgdqljs_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查流行病学史' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_lxbxs_zgdqljs_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">
                          {{ dict.epidemic.desc2 }}
                        </div>
                        <div class="card-item-content">
                          <van-field
                            name="is_lxbxs_jwljs_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查流行病学史' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_lxbxs_jwljs_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">
                          {{ dict.epidemic.desc3 }}
                        </div>
                        <div class="card-item-content">
                          <van-field
                            name="is_lxbxs_jcfrhz_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查流行病学史' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_lxbxs_jcfrhz_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">
                          {{ dict.epidemic.desc4 }}
                        </div>
                        <div class="card-item-content">
                          <van-field
                            name="is_lxbxs_jcxggrz_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查流行病学史' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_lxbxs_jcxggrz_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">
                          {{ dict.epidemic.desc5 }}
                        </div>
                        <div class="card-item-content">
                          <van-field
                            name="is_lxbxs_jjx_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查流行病学史' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_lxbxs_jjx_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div class="card risk mt20">
                    <div class="card-bar">
                      <div class="card-bar-title">风险人群</div>
                    </div>
                    <div class="card-container">
                      <div class="card-container-item">
                        <div class="card-item-label">{{ dict.risk.desc1 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_lxbxs_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_lxbxs_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-subtitle">
                          {{ dict.risk.subtitle1 }}
                        </div>
                        <div class="card-item-label">{{ dict.risk.desc2 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_jkll_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_jkll_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">{{ dict.risk.desc3 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_jzyx_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_jzyx_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">{{ dict.risk.desc4 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_xgfy_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_xgfy_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">{{ dict.risk.desc5 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_bj_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_bj_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                      <div class="card-container-item">
                        <div class="card-item-label">{{ dict.risk.desc6 }}</div>
                        <div class="card-item-content">
                          <van-field
                            name="is_fxrq_nrsq_br"
                            :required="false"
                            :rules="[
                              { required: true, message: '请检查风险人群' },
                            ]"
                            label="本人"
                          >
                            <template #input>
                              <van-radio-group
                                v-model="item.form.is_fxrq_nrsq_br"
                                checked-color="#D58913"
                                direction="horizontal"
                              >
                                <van-radio name="1">是</van-radio>
                                <van-radio name="0">否</van-radio>
                              </van-radio-group>
                            </template>
                          </van-field>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div class="card file mt20">
                    <div class="card-bar">
                      <div class="card-bar-title">上传附件</div>
                    </div>
                    <div class="card-container">
                      <van-field label="核酸检测报告" name="nucleic_test_image">
                        <template #input>
                          <Uploader
                            v-model="item.form.nucleic_test_image"
                            :max-count="1"
                            file-dir="dlSchool/health/hsbg"
                          ></Uploader>
                        </template>
                      </van-field>
                      <van-field label="健康码" name="health_code_image">
                        <template #input>
                          <Uploader
                            v-model="item.form.health_code_image"
                            :max-count="1"
                            file-dir="dlSchool/health/jkm"
                          ></Uploader>
                        </template>
                      </van-field>
                      <van-field label="行程码" name="trip_code_image">
                        <template #input>
                          <Uploader
                            v-model="item.form.trip_code_image"
                            :max-count="1"
                            file-dir="dlSchool/health/xcm"
                          ></Uploader>
                        </template>
                      </van-field>
                    </div>
                  </div>
                </van-collapse-item>
              </van-collapse>
            </div>
          </div>
        </div>

        <div class="footer">
          <div class="footer-content">
            <div>以上信息请如实填写，确保所填信息真实性</div>
            <div>如有提供虚假信息，需承担相应法律责任</div>
          </div>
        </div>
      </van-form>
    </div>

    <div class="bottom-bar">
      <van-button
        class="bottom-bar-btn"
        block
        size="large"
        color="#D58913"
        type="info"
        text="确认提交"
        @click="beforeSubmitAction"
      />
    </div>
  </div>
</template>

<script>
import dict from './dict/others'
import { identityCodeValid, identityTemp } from '@/libs/tools'
import {
  getDLAreaList,
  getResidentAllList,
  getHealthInfo,
  getFillingList,
  getStudentInfoById,
  getTeacherInfoById,
  getWorkerInfoById,
  saveHealthInfo,
  gethsjcsj,
  getYmjzqk,
} from '@/api/school'
import Map from '@/views/school/components/map'
import Resident from '@/views/school/components/resident'
import Uploader from '@/components/uploader'

export default {
  components: { Map, Resident, Uploader },
  data() {
    return {
      dict,
      route: {},
      userInfo: {},
      popupShow: false,
      popupState: '',
      pickerType: '',
      pickerData: [],
      userData: {},
      disabled: {},
      fillingList: [],
      activeNames: [],
      formData: [
        {
          discomfortArr: [],
          paramList: [],
          body_situation: '0',
          temperature: 36.5,
          is_lxbxs_zgdqljs_br: '0',
          is_lxbxs_jwljs_br: '0',
          is_lxbxs_jcfrhz_br: '0',
          is_lxbxs_jcxggrz_br: '0',
          is_lxbxs_jjx_br: '0',
          is_fxrq_lxbxs_br: '0',
          is_fxrq_jkll_br: '0',
          is_fxrq_jzyx_br: '0',
          is_fxrq_xgfy_br: '0',
          is_fxrq_bj_br: '0',
          is_fxrq_nrsq_br: '0',
          vacciens_inoculation: 0,
        },
      ],
      cascaderShow: false,
      cascaderValue: '',
      resident_id: '',
      cascadeOptions: [],
      fieldNames: {
        text: 'name',
        value: 'code',
        children: 'children',
      },
      dictData: {},
      residentList: [],
    }
  },
  computed: {},
  watch: {},
  mounted() {
    this.route = this.$route.query
    this.init()
  },
  methods: {
    radioChange(value, type, index) {
      switch (type) {
        case 'body_situation':
          if (value == 0) {
            this.formData[index].discomfortArr = []
            this.formData[index].symptom = ''
          }
          break
      }
    },
    async init() {
      // 获取区域所属
      const areaData = await getDLAreaList()
      if (areaData.data.errcode == 0) {
        let options = this.$common.xeUtils.toArrayTree(areaData.data.data, {
          strict: true,
          parentKey: 'parent_id',
          key: 'id',
          children: 'children',
        })
        this.cascadeOptions = options[0].children
      }
      // 获取基本信息
      let apiName = null
      let param = { type: this.route.type }
      switch (this.route.type) {
        case 'children':
          apiName = getStudentInfoById
          param.id = this.formData[0].student_id = this.route.student_id
          this.formData[0].parent_id = this.route.parent_id
          break
        case 'teacher':
          apiName = getTeacherInfoById
          param.id = this.formData[0].teacher_id = this.route.teacher_id
          break
        case 'worker':
          apiName = getWorkerInfoById
          param.id = this.formData[0].workers_id = this.route.workers_id
          break
      }
      this.formData[0].type = this.route.type
      const baseInfo = await apiName(param)
      if (baseInfo.data.errcode == 0) {
        this.$set(this.formData[0], 'name', baseInfo.data.data.name)
        this.$set(this.formData[0], 'card_no', baseInfo.data.data.card_no)
        this.$set(
          this.formData[0],
          'card_no_tmd',
          baseInfo.data.data.card_no_tmd
        )
        this.$set(this.formData[0], 'mobile', baseInfo.data.data.tel)
        this.$set(this.formData[0], 'lng', baseInfo.data.data.lng)
        this.$set(this.formData[0], 'lat', baseInfo.data.data.lat)
        this.getFillingList(baseInfo.data.data.school_id)
        // 获取本人核酸信息
        gethsjcsj({
          card_no: baseInfo.data.data.card_no,
        }).then((res) => {
          if (res.data.errcode === 0 && res.data.data) {
            this.$set(listItem.form, 'hs_time', res.data.data.hsjcsj)
          }
        })
        // 获取本人疫苗信息
        getYmjzqk({ card_no: baseInfo.data.data.card_no }).then((res) => {
          if (res.data.errcode === 0) {
            if (res.data.data.count) {
              this.$set(
                this.formData[0],
                'ym_time',
                '已接种' + res.data.data.count + '针'
              )
            }
          }
        })
      }
      // 获取居住人列表
      this.getResidentList()
      // 获取历史填报信息
      const healthInfo = await getHealthInfo(param)
      if (
        healthInfo.data.errcode == 0 &&
        healthInfo.data.data &&
        healthInfo.data.data.length > 0
      ) {
        this.formData = healthInfo.data.data
        healthInfo.data.data.forEach((formItem, index) => {
          if (healthInfo.data.data[index].lng)
            this.$set(
              this.formData[index],
              'lng',
              healthInfo.data.data[index].lng
            )
          if (healthInfo.data.data[index].lat)
            this.$set(
              this.formData[index],
              'lat',
              healthInfo.data.data[index].lat
            )
          if (healthInfo.data.data[index].create_time)
            this.$set(
              this.formData[index],
              'create_time',
              healthInfo.data.data[index].create_time
            )
          /*基本情况*/
          if (healthInfo.data.data[index].body_situation)
            this.$set(
              this.formData[index],
              'body_situation',
              healthInfo.data.data[index].body_situation
            )
          if (healthInfo.data.data[index].symptom) {
            this.$set(
              this.formData[index],
              'discomfortArr',
              healthInfo.data.data[index].symptom.split(',')
            )
            this.$set(
              this.formData[index],
              'symptom',
              healthInfo.data.data[index].symptom
            )
          }
          if (healthInfo.data.data[index].temperature)
            this.$set(
              this.formData[index],
              'temperature',
              healthInfo.data.data[index].temperature
            )
          if (healthInfo.data.data[index].area_code)
            this.$set(
              this.formData[index],
              'area_code',
              healthInfo.data.data[index].area_code
            )
          if (healthInfo.data.data[index].area_name)
            this.$set(
              this.formData[index],
              'area_name',
              healthInfo.data.data[index].area_name
            )
          if (healthInfo.data.data[index].street_code)
            this.$set(
              this.formData[index],
              'street_code',
              healthInfo.data.data[index].street_code
            )
          if (healthInfo.data.data[index].street_name)
            this.$set(
              this.formData[index],
              'street_name',
              healthInfo.data.data[index].street_name
            )
          if (healthInfo.data.data[index].community_code)
            this.$set(
              this.formData[index],
              'community_code',
              healthInfo.data.data[index].community_code
            )
          if (healthInfo.data.data[index].community_name)
            this.$set(
              this.formData[index],
              'community_name',
              healthInfo.data.data[index].community_name
            )
          if (healthInfo.data.data[index].quarter)
            this.$set(
              this.formData[index],
              'quarter',
              healthInfo.data.data[index].quarter
            )
          if (healthInfo.data.data[index].community_code)
            this.$set(
              this,
              'cascaderValue',
              healthInfo.data.data[index].community_code
            )
          if (
            healthInfo.data.data[index].area_name &&
            healthInfo.data.data[index].street_name &&
            healthInfo.data.data[index].community_name
          ) {
            this.$set(
              this.formData[index],
              'ascription',
              healthInfo.data.data[index].area_name +
                '/' +
                healthInfo.data.data[index].street_name +
                '/' +
                healthInfo.data.data[index].community_name
            )
          }
          if (healthInfo.data.data[index].address)
            this.$set(
              this.formData[index],
              'address',
              healthInfo.data.data[index].address
            )
          /*流行病学史*/
          if (healthInfo.data.data[index].is_lxbxs_zgdqljs_br)
            this.$set(
              this.formData[index],
              'is_lxbxs_zgdqljs_br',
              healthInfo.data.data[index].is_lxbxs_zgdqljs_br
            )
          if (healthInfo.data.data[index].is_lxbxs_jwljs_br)
            this.$set(
              this.formData[index],
              'is_lxbxs_jwljs_br',
              healthInfo.data.data[index].is_lxbxs_jwljs_br
            )
          if (healthInfo.data.data[index].is_lxbxs_jcfrhz_br)
            this.$set(
              this.formData[index],
              'is_lxbxs_jcfrhz_br',
              healthInfo.data.data[index].is_lxbxs_jcfrhz_br
            )
          if (healthInfo.data.data[index].is_lxbxs_jcxggrz_br)
            this.$set(
              this.formData[index],
              'is_lxbxs_jcxggrz_br',
              healthInfo.data.data[index].is_lxbxs_jcxggrz_br
            )
          if (healthInfo.data.data[index].is_lxbxs_jjx_br)
            this.$set(
              this.formData[index],
              'is_lxbxs_jjx_br',
              healthInfo.data.data[index].is_lxbxs_jjx_br
            )
          /*风险人群*/
          if (healthInfo.data.data[index].is_fxrq_lxbxs_br)
            this.$set(
              this.formData[index],
              'is_fxrq_lxbxs_br',
              healthInfo.data.data[index].is_fxrq_lxbxs_br
            )
          if (healthInfo.data.data[index].is_fxrq_jkll_br)
            this.$set(
              this.formData[index],
              'is_fxrq_jkll_br',
              healthInfo.data.data[index].is_fxrq_jkll_br
            )
          if (healthInfo.data.data[index].is_fxrq_jzyx_br)
            this.$set(
              this.formData[index],
              'is_fxrq_jzyx_br',
              healthInfo.data.data[index].is_fxrq_jzyx_br
            )
          if (healthInfo.data.data[index].is_fxrq_xgfy_br)
            this.$set(
              this.formData[index],
              'is_fxrq_xgfy_br',
              healthInfo.data.data[index].is_fxrq_xgfy_br
            )
          if (healthInfo.data.data[index].is_fxrq_bj_br)
            this.$set(
              this.formData[index],
              'is_fxrq_bj_br',
              healthInfo.data.data[index].is_fxrq_bj_br
            )
          if (healthInfo.data.data[index].is_fxrq_nrsq_br)
            this.$set(
              this.formData[index],
              'is_fxrq_nrsq_br',
              healthInfo.data.data[index].is_fxrq_nrsq_br
            )
          if (healthInfo.data.data[index].nucleic_test_image)
            this.$set(
              this.formData[index],
              'nucleic_test_image',
              healthInfo.data.data[index].nucleic_test_image.replace(
                'http://10.195.107.22:9864',
                'http://daliandl.lngov.top'
              )
            )
          if (healthInfo.data.data[index].health_code_image)
            this.$set(
              this.formData[index],
              'health_code_image',
              healthInfo.data.data[index].health_code_image.replace(
                'http://10.195.107.22:9864',
                'http://daliandl.lngov.top'
              )
            )
          if (healthInfo.data.data[index].trip_code_image)
            this.$set(
              this.formData[index],
              'trip_code_image',
              healthInfo.data.data[index].trip_code_image.replace(
                'http://10.195.107.22:9864',
                'http://daliandl.lngov.top'
              )
            )
          if (healthInfo.data.data[index].param) {
            this.$set(
              this.formData[index],
              'paramList',
              JSON.parse(healthInfo.data.data[index].param)
            )
            if (
              this.formData[index].paramList.length > 0 &&
              this.fillingList.length > 0
            ) {
              this.formData[index].paramList.forEach((paramItem) => {
                this.fillingList.forEach((fillingItem) => {
                  if (paramItem.id == fillingItem.id) {
                    this.$set(
                      this.formData[index],
                      fillingItem.key_num,
                      paramItem[fillingItem.key_num]
                    )
                  }
                })
              })
            }
          } else {
            this.$set(this.formData[index], 'paramList', [])
          }
          this.residentList.forEach((listItem) => {
            if (listItem.id == formItem.cohabitation_id) {
              listItem.isChecked = true
            }
          })
        })
      }
      // 设置当日日期
      this.$set(
        this.formData[0],
        'c_date',
        this.$common.xeUtils.toDateString(new Date(), 'yyyy-MM-dd')
      )
      this.$set(
        this.formData[0],
        'date',
        this.$common.xeUtils.toDateString(new Date(), 'yyyyMMdd')
      )
    },
    async getFillingList(school_id) {
      const fillingList = await getFillingList({ school_id: school_id })
      if (fillingList.data.errcode == 0) {
        this.fillingList = fillingList.data.data
        if (this.formData.length > 0) {
          this.formData.forEach((formItem, index) => {
            if (
              this.formData[index].paramList.length > 0 &&
              this.fillingList.length > 0
            ) {
              this.formData[index].paramList.forEach((paramItem) => {
                this.fillingList.forEach((fillingItem) => {
                  if (paramItem.id == fillingItem.id) {
                    this.$set(
                      this.formData[index],
                      fillingItem.key_num,
                      paramItem[fillingItem.key_num]
                    )
                  }
                })
              })
            }
          })
        }
      }
    },
    async getResidentList() {
      const residentInfo = await getResidentAllList({
        ...this.route,
        card_no: this.formData[0].card_no,
      })
      if (residentInfo.data.errcode == 0) {
        residentInfo.data.data.forEach((listItem) => {
          listItem.isChecked = false
          listItem.form = {
            c_date: this.formData[0].c_date,
            cohabitation_id: listItem.id,
            name: listItem.name,
            mobile: listItem.tel,
            card_no: listItem.card_no,
            card_no_tmd: listItem.card_no_tmd,
            discomfortArr: [],
            paramList: [],
            body_situation: '0',
            temperature: 36.5,
            is_lxbxs_zgdqljs_br: '0',
            is_lxbxs_jwljs_br: '0',
            is_lxbxs_jcfrhz_br: '0',
            is_lxbxs_jcxggrz_br: '0',
            is_lxbxs_jjx_br: '0',
            is_fxrq_lxbxs_br: '0',
            is_fxrq_jkll_br: '0',
            is_fxrq_jzyx_br: '0',
            is_fxrq_xgfy_br: '0',
            is_fxrq_bj_br: '0',
            is_fxrq_nrsq_br: '0',
            vacciens_inoculation: 0,
            ...this.route,
          }
          // 获取核酸信息
          gethsjcsj({
            card_no: listItem.card_no,
          }).then((res) => {
            if (res.data.errcode === 0 && res.data.data) {
              this.$set(listItem.form, 'hs_time', res.data.data.hsjcsj)
            }
          })
          // 获取疫苗信息
          getYmjzqk({ card_no: listItem.card_no }).then((res) => {
            if (res.data.errcode === 0) {
              if (res.data.data.count) {
                this.$set(
                  listItem.form,
                  'ym_time',
                  '已接种' + res.data.data.count + '针'
                )
              }
            }
          })
          this.formData.forEach((formItem) => {
            if (listItem.id == formItem.cohabitation_id) {
              listItem.isChecked = true
              listItem.form = { ...listItem.form, ...formItem }
            }
          })
        })
        this.residentList = residentInfo.data.data
      }
    },
    editAction(item) {
      this.resident_id = item.id
      this.pickerChange('gtjzz')
    },
    pickerChange(type) {
      this.pickerType = type
      switch (type) {
        case 'ascription':
          this.popupState = 'cascader'
          this.popupShow = true
          break
        case 'map':
          this.popupState = 'map'
          this.popupShow = true
          break
        case 'gtjzz':
          this.popupState = 'gtjzz'
          this.popupShow = true
          break
        // case 'relationship':
        //   this.popupState = 'picker'
        //   this.pickerType = 'relationship'
        //   this.pickerData = this.dictData.relationship
        //   this.popupShow = true
        //   break
      }
    },
    pickerConfirm(e) {
      switch (
        this.pickerType
        // case 'relationship':
        //   this.formData.relationship_name = e.text
        //   this.formData.relationship = e.value
        //   this.popupShow = false
        //   break
      ) {
      }
    },
    pickerCancel(e) {
      switch (
        this.pickerType
        // case 'relationship':
        //   this.formData.relationship_name = ''
        //   this.formData.relationship = ''
        //   this.popupShow = false
        //   break
      ) {
      }
    },
    cascaderFinish({ value, selectedOptions, tabIndex }) {
      this.formData[0].ascription =
        selectedOptions[0].name +
        '/' +
        selectedOptions[1].name +
        '/' +
        selectedOptions[2].name
      this.formData[0].area_code = selectedOptions[0].code
      this.formData[0].street_code = selectedOptions[1].code
      this.formData[0].community_code = selectedOptions[2].code
      this.formData[0].area_name = selectedOptions[0].name
      this.formData[0].street_name = selectedOptions[1].name
      this.formData[0].community_name = selectedOptions[2].name
      this.popupClose()
    },
    cascaderClose() {
      this.formData[0].ascription = ''
      this.formData[0].area_code = ''
      this.formData[0].street_code = ''
      this.formData[0].community_code = ''
      this.formData[0].area_name = ''
      this.formData[0].street_name = ''
      this.formData[0].community_name = ''
      this.popupClose()
    },
    failNotice(msg) {
      this.$notify({ type: 'danger', message: msg })
    },
    onFailed(errorInfo) {
      this.failNotice(errorInfo.errors[0].message)
    },
    // 体温校验
    tempValidator(val) {
      return identityTemp(val)
    },
    beforeSubmitAction() {
      this.$refs.form.submit()
    },
    getLngLat(e) {
      this.formData[0].lng = e.lng
      this.formData[0].lat = e.lat
      this.popupClose()
    },
    getResident() {
      this.getResidentList()
      this.popupClose()
    },
    popupClose() {
      this.popupState = ''
      this.resident_id = ''
      this.popupShow = false
    },
    onSubmit() {
      //附件校验
      // if (
      //   !this.formData[0].nucleic_test_image ||
      //   !this.formData[0].health_code_image ||
      //   !this.formData[0].trip_code_image
      // ) {
      //   this.$notify({ type: 'danger', message: '请检查附件' })
      //   return
      // }
      // for (let i = 0; i < this.residentList.length; i++) {
      //   if (this.residentList[i].isChecked) {
      //     if (
      //       !this.residentList[i].form.nucleic_test_image ||
      //       !this.residentList[i].form.health_code_image ||
      //       !this.residentList[i].form.trip_code_image
      //     ) {
      //       this.$notify({ type: 'danger', message: '请检查附件' })
      //       return
      //     }
      //   }
      // }
      //校验
      const today = this.$common.xeUtils.toDateString(new Date(), 'yyyy-MM-dd')
      const latest = this.$common.xeUtils.toDateString(
        this.formData[0].create_time || '',
        'yyyy-MM-dd'
      )
      // if (today == latest) {
      //   this.$toast('当日已填报，请勿重复上报')
      //   return
      // }
      // 获取位置
      this.submitAction()
    },
    submitAction() {
      // 数据处理
      for (let index = 0; index < this.formData.length; index++) {
        this.formData.pop()
      }
      this.residentList.forEach((residentItem) => {
        if (residentItem.isChecked) {
          this.formData.push(residentItem.form)
        }
      })
      this.formData.forEach((formItem) => {
        formItem.paramList = []
        if (formItem.discomfortArr) {
          formItem.symptom = formItem.discomfortArr.join(',')
        }
        this.fillingList.forEach((fillingItem) => {
          const { key_num } = fillingItem
          formItem.paramList.push({
            id: fillingItem.id,
            filling_contents: fillingItem.filling_contents,
            [key_num]: formItem[fillingItem.key_num],
          })
        })
        formItem.param = JSON.stringify(formItem.paramList)
      })
      // 提交
      this.$dialog
        .confirm({
          title: '是否确认提交',
          message: '',
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          confirmButtonColor: '#D58913',
          beforeClose: async (action, done) => {
            if (action === 'confirm') {
              const insertData = await saveHealthInfo({ list: this.formData })
              if (insertData.data.errcode == 0) {
                this.$toast('操作成功')
                setTimeout(() => {
                  // this.$router.go(-1)
                 this.$router.push({
                    path: '/school',
                    query:{
                      ...this.$store.state.user.userInfo
                    }
                  })
                }, 500)
                done()
              } else {
                this.$toast(insertData.data.errmsg)
                done()
              }
            } else {
              done()
            }
          },
        })
        .catch(() => {})
    },
  },
}
</script>

<style lang="less" scoped>
.container /deep/ .van-checkbox {
  min-height: 30px;
}

.container /deep/ .van-field__label span {
  display: inline-block;
  padding-left: 5px;
  width: 82%;
  text-align-last: justify;
}

.van-cell::after {
  display: none;
}

.container {
  background: url('../../assets/images/school/bg_health.jpg') no-repeat;
  background-size: contain;
  //background: #F2F7FB;
  width: 100%;
  height: 100vh;
  box-sizing: border-box;
  color: black;

  &-inner {
    padding: 130px 20px 50px;
    overflow: auto;

    .card {
      background: inherit;

      &-container {
        border-radius: 10px;
        overflow: hidden;
        background-color: white;
        padding: 10px;

        &-item {
          margin-bottom: 10px;
        }

        &-item:not(:last-child) {
          border-bottom: 1px solid #ebedf0;
        }
      }

      &-item {
        &-subtitle {
          padding: 0px 5px;
          font-size: 15px;
          margin-bottom: 5px;
        }

        &-label {
          color: #a0a0a0;
          font-size: 14px;
          position: relative;
          padding-left: 20px;
          padding-right: 10px;
        }

        &-label::before {
          position: absolute;
          left: 8px;
          color: #ee0a24;
          font-size: 14px;
          content: '*';
        }
      }

      &-gtjzz {
        display: flex;
        justify-content: space-between;

        &-btn {
          border-radius: 5px;
        }
      }
    }
  }

  .footer {
    padding: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;

    &-content {
      width: 80%;
      display: inline-block;
      text-align: center;

      & > div {
        display: inline-block;
        color: #bbb;
        font-weight: bold;
      }
    }

    &::before,
    &::after {
      content: '';
      width: 10%;
      border-top: 1px #bbb solid;
      display: inline-block;
      vertical-align: middle;
    }
  }

  .bottom-bar {
    position: fixed;
    bottom: 0;
    width: 100%;
  }

  .residentlist {
    display: flex;
    justify-content: flex-start;
    flex-flow: wrap;
    align-items: center;
    padding-top: 10px;

    &-item {
      box-sizing: border-box;
      padding: 5px;
      width: 100%;
      text-align: center;
      border: 1px solid #898989;
      border-radius: 10px;
      margin: 10px 0;
      cursor: pointer;

      &-bottom {
        display: flex;
        justify-content: space-around;
        margin-top: 20px;

        &-btn {
          width: 40%;
          border-radius: 5px;
        }
      }

      .desc {
        margin-top: 10px;
        font-weight: 400;
        font-size: 20px;
        text-align: left;
        color: #b4b4b4;
      }

      &-active {
        box-shadow: 0px 0px 5px 3px rgba(255, 145, 0, 0.8);
        border: 1px solid #ff9100;
      }
    }
  }
}
.tag {
  margin-left: 10px;
  padding: 2px 5px;
  width: auto;
  height: auto;
  font-size: 12px;
  border-radius: 3px;
  text-align: center;
  background: rgba(211, 211, 211, 0.5);
  border: 1px solid grey;
  color: grey;
}
.field-title {
  display: inline-block;
  padding-left: 5px;
  width: 82%;
  text-align-last: justify;
}
.field-text {
  padding: 0 5px;
  font-size: 12px;
}
</style>
